import {Injectable} from '@angular/core';
import {HttpService} from '../../../core/http.service';
import {CommHttpService} from '../../../core/comm.http.service';
import {SERVERS_NAME} from '../../../config/config';
import {Observable} from 'rxjs';

@Injectable()
export class CourseManageService extends CommHttpService {
    protected preUrl = `${SERVERS_NAME.EVALUTE_SERVER}base/course/`;

    constructor(protected http: HttpService) {
        super(http);
    }

    /**********接口部分**********/

    /**
     * 查询学年列表
     */
    year(): Observable<any> {
      return this.http.post({}, `${SERVERS_NAME.SECURITY_SERVER}sys/semester/list`);
    }

  /**
   * 获取教师
   */
  getTeachList(data) {
    return this.http.post(data, `${SERVERS_NAME.SECURITY_SERVER}sys/teacher/listAndPhone`);
  }

  /**
   * 查询学院列表
   */
  getCollege() {
    return this.http.get({}, `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/dept/list');
  }

  /**
   * 查询专业列表
   */
  getMajor(id) {
    return this.http.post([id], `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/college/listMajor', false);
  }

  /**
   * 查询班级列表
   */
  getClass(id) {
    return this.http.post([id], `${SERVERS_NAME.SECURITY_SERVER}` + 'sys/classes/list', false);
  }

    /**
     * 试题列表批量删除
     * @param param： param
     */
    deleteAll(param: Array<string>): Observable<any> {
        return this.http.post(param, this.preUrl + `deleteAll`);
    }

  /**
   * 发布
   * @param param： param
   */
  setEvalute(param): Observable<any> {
    return this.http.post(param, this.preUrl + `evalute`);
  }


    /**
     * 获取分页
     * @param param：param
     */
    getPage(param: any): Observable<any> {
        return this.http.post(param, this.preUrl + `page`);
    }

    /**
     * 获取学生详情分页
     * @param param：param
     */
    pageForStudent(param: any): Observable<any> {
        return this.http.post(param, this.preUrl + `pageForStudent`);
    }

    /**
     * 导入Excel
     *
     * @returns Observable<any>返回值
     * @param data: 数据参数
     */
    importExcel(data: any): Observable<any> {
        return this.http.postFile(data, `${SERVERS_NAME.SAFETY_EDU}` + 'safety/edu/question/import');
    }

    stuList(data) {
      return this.http.post(data, `${SERVERS_NAME.EVALUTE_SERVER}` + 'evalute/studentPaper/findAll');
    }

    schoolList(data) {
      return this.http.post(data, `${SERVERS_NAME.EVALUTE_SERVER}` + 'evalute/supervise/findAll');
    }

    getPageColsApi() {
      return this.http.get('', `${this.preUrl}pageCols`);
    }

  // 获取默认模板
  getDef() {
    return this.http.post({}, `${SERVERS_NAME.EVALUTE_SERVER}evalute/studentPaper/getDefault`);
  }

}
